﻿function RandomPopulator(i)
{
	Populator.ResetActors();
	
	for(var j = 0; j < i; j++)
	{
		var agent = new Agent();
		agent.ActorParams.x = (Math.random() * 2 - 1) * 50;
		agent.ActorParams.y = (Math.random() * 2 - 1) * 50;
		agent.ActorParams.DestinationX = (Math.random() * 2 - 1) * 50;
		agent.ActorParams.DestinationY = (Math.random() * 2 - 1) * 50;
		
		agent.ActorParams.velocityAngle = Math.atan2(
			(agent.ActorParams.DestinationY - agent.ActorParams.y),
			(agent.ActorParams.DestinationX - agent.ActorParams.x));
			
		agent.ActorParams.velocityRadius = 3;
		
		
		
		actors.push(agent);
		
	}
	
	this.Update = RandomDestinationUpdater();
}

function RandomDestinationUpdater()
{
	for(var j = 0; j < i; j++)
	{
		
		var agent = actors[i];
		var params = agent.params;
		
		var x = params.x - params.DesitanationX;
		var y = params.y - params.DesitanationY;
		
		if(length(x,y) < params.radius)
		{
		
		
		
		
		agent.ActorParams.DestinationX = (Math.random() * 2 - 1) * 50;
		agent.ActorParams.DestinationY = (Math.random() * 2 - 1) * 50;
		
		
		}		
	}

}

